package com.xm.queue.task;

import lombok.extern.slf4j.Slf4j;

/**
 * 模拟异常任务本身耗时 500 毫秒
 */
@Slf4j
public class AsyncTask implements Runnable {
    private final String taskName;

    public AsyncTask(String taskName) {
        this.taskName = taskName;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(500L);
            if (taskName != null && taskName.startsWith("test")) {
                log.info("[{}]正在执行任务 {}", Thread.currentThread().getName(), taskName);
            }
        } catch (InterruptedException e) {
            throw new RuntimeException("执行异步任务异常", e);
        }
    }
}
